package com.yixun.qfbao.hander;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yixun.qfbao.api.service.OrganizationService;
import com.yixun.qfbao.apidto.AgentOrgAuditReqDto;
import com.yixun.qfbao.apidto.AgentOrgAuditResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.model.PartnerInfo;
import com.yixun.qfbao.util.exception.TServerException;
import com.yixun.qfbao.utils.LoginUtils;
import com.yixun.qfbao.vo.AgentOrgAuditReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

/**
 * 分销机构审核
 * @author xiaojin.li
 *
 */
@Service("agentOrgAuditHander")
public class AgentOrgAuditHander extends CommonAbstractHander {
	private static Logger logger= LoggerFactory.getLogger(AgentOrgAuditHander.class);
	
	@Autowired
	private OrganizationService organizationService;
	
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		AgentOrgAuditReqVo req = (AgentOrgAuditReqVo)reqDto;
		AgentOrgAuditReqDto reqDto1 = req.getParams();
		BaseResponseDTO<AgentOrgAuditResDto> res = new BaseResponseDTO<AgentOrgAuditResDto>();
		AgentOrgAuditResDto resDto = new AgentOrgAuditResDto();
		try {
			resDto = organizationService.agentOrgAudit(reqDto1);
		}catch(TServerException e){
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg(e.getErrorMsg());
		} catch (Exception e) {
			logger.error("AgentOrgAuditHander error: {}", e);
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg("系统异常");
		}
		res.setResData(resDto);
		res.setResult(resDto.getResult());
		return res;
	}
	
}
